import { defineStore } from 'pinia'

export const useStateStore = defineStore('state', {
  state: () => ({
    //加载 true/false
    loadingGlobal: false,

    //平台名称
    platformName: '吉合号后台管理平台',
    //平台logo地址
    platformLogo: require('@/assets/imgs/logo2.png'),

    //客服电话
    servicePhone: '',
    //客服名称
    serviceName: '',

    //鉴权信息
    platformHeadType: 'rcmsPlatform',
    Authorization: JSON.parse(window.localStorage.getItem("JHH_USER_AUTHOR")) || { Authorization: `'','','',3,20,''` },

    //可见菜单id集合
    menuIds: [],
  }),
  getters: {
    getLoadingGlobal: (state) => {
      return state.loadingGlobal
    },
    getPlatformName: (state) => {
      return state.platformName
    },
    getPlatformLogo: (state) => {
      return state.platformLogo
    },
    getPlatformHeadType: (state) => {
      return state.platformHeadType
    },
    getAuthorization: (state) => {
      return state.Authorization.Authorization
    },
    getMenuIds: (state) => {
      return state.menuIds
    },
    getServicePhone: (state) => {
      return state.servicePhone
    },
    getServiceName: (state) => {
      return state.serviceName
    },
  },
  actions: {
    setLoadingGlobal(is) {
      this.loadingGlobal = is
    },
    setLoadingGlobal(name) {
      this.platformName = name
    },
    setPlatformLogo(url) {
      this.platformLogo = url
    },
    setPlatformHeadType(type) {
      this.platformHeadType = type
    },
    setAuthorization(Authorization) {
      this.Authorization = Authorization
    },
    setMenuIds(list) {
      this.menuIds = list
    },
  },
})